//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//

package SaveServlet.manager;

import com.lyq.bean.service.M_Service;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet(
        name = "AddManager_Servlet",
        urlPatterns = {"/AddManager_Servlet"}
)
public class AddManager_Servlet extends HttpServlet {
    private static final long serialVersionUID = 1L;

    public AddManager_Servlet() {
    }

    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String username = request.getParameter("username");
        String pwd = request.getParameter("password");
        Boolean bool = (new M_Service()).add_M(username, pwd);
        if (bool) {
            request.getSession().setAttribute("message", "添加管理员成功！");
        } else {
            request.getSession().setAttribute("message", "该用户名已存在，添加管理员失败！");
        }

        request.getSession().setAttribute("url", "jsp/manager/AddManager.jsp");
        request.getRequestDispatcher("Message.jsp").forward(request, response);
    }
}
